package com.jingyi.web.controller.tool;

import com.jingyi.common.annotation.Anonymous;
import com.jingyi.common.annotation.CheckOpenId;
import com.jingyi.common.constant.Constants;
import com.jingyi.common.core.domain.R;
import com.jingyi.common.utils.uuid.IdUtils;
import com.jingyi.framework.web.service.TokenService;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("用户信息管理")
@RestController
@RequestMapping("/test/jwt")
public class TestJwtController {
    @Autowired
    TokenService tokenService;


    @ApiOperation("获取用户列表")
    @GetMapping("/test")
    @CheckOpenId
    public void userList()
    {
        Map<String, Object> claims = new HashMap<>();
        String uuid = IdUtils.fastUUID();
        claims.put("type","wechat");
        claims.put(Constants.LOGIN_USER_KEY, uuid);
        System.out.println("======================================================");
        String token = tokenService.createToken(claims);
        System.out.println(token);
        System.out.println("======================================================");
        Claims claim = tokenService.parseToken(token);
        String uid = (String) claims.get(Constants.LOGIN_USER_KEY);
        String type = (String) claims.get("type");
        System.out.println(type);

    }
}
